package gases.as3.librarys.components.containui
{
	import gases.as3.librarys.components.skin.data.BaseSkin;
	import gases.as3.librarys.components.ui.GUIComponents;
	import gases.as3.librarys.components.ui.basic.GLabel;
	import gases.as3.librarys.components.ui.text.GTextInput;
	
	public class FormItem extends GUIComponents
	{
		public function FormItem(viewstyle:int=1,labeltxt:String = "",labelwidth:Number = 120,labelheight:Number = 20,
								 inputtxt:String = "",inputwidth:Number = 80,inputheight:Number = 20,gap:Number = 1,labelColor:uint=0x00cc00,inputColor:uint=0x00cc00)
		{
			_viewStyle = viewstyle;
			_labelTxt = labeltxt;
			_inputTxt = inputtxt;
			_labelWidth = labelwidth;
			_labelHeight = labelheight;
			_inputWidth = inputwidth;
			_inputHeight = inputheight;
			_labelColor = labelColor;
			_inputColor = inputColor;
			_gap = gap;
			super();
		}
		
		override protected function initialization():void
		{
			super.initialization();
			
			_label = new GLabel(_labelTxt,_labelColor,12,_labelWidth,_labelHeight);
			_input = new GTextInput(_inputTxt,_inputWidth,_inputHeight);
			_input.color = _labelColor;
			this.addChild(_label);
			this.addChild(_input);
			
			setStyle();
		}
		
		public function setSkin(inputSkin:BaseSkin):void
		{
			if(!inputSkin)
			{
				return;
			}
			_input.skin = inputSkin;
		}
		
		public function setLabelTxt(value:String):void
		{
			_label.text = value;
		}
		
		public function setInputTxt(value:String):void
		{
			_input.text = value;
		}
		
		public function get labelTxt():String
		{
			return _label.text;
		}
		
		public function get inputTxt():String
		{
			return _input.text;
		}
		
		public function set inputColor(value:uint):void
		{
			_inputColor = value;
		}
		
		public function get inputColor():uint
		{
			return _inputColor;
		}
		
		public function set labelColor(value:uint):void
		{
			_labelColor = value;
		}
		
		public function get labelColor():uint
		{
			return _labelColor;
		}
		
		public function setViewStyle(value:int):void
		{
			_viewStyle = value;
			setStyle();
		}
		
		public function setInputIsPassword(value:Boolean):void
		{
			_input.isPassword = value;
		}
		
		public function setInputRestrict(value:String):void
		{
			_input.restrict = value;
		}
		
		private function setStyle():void
		{
			switch(_viewStyle)
			{
				case 1:
					_input.x = _label.Gwidth + _gap;
					break;
				case 2:
					_label.x = _input.Gwidth + _gap;
					break;
			}
		}
		
		
		private var _labelTxt:String;
		private var _inputTxt:String;
		private var _labelWidth:Number;
		private var _labelHeight:Number;
		private var _inputWidth:Number;
		private var _inputHeight:Number;
		private var _gap:Number;
		
		private var _labelColor:uint;
		private var _inputColor:uint;
		
		private var _viewStyle:int;
		
		private var _label:GLabel;
		private var _input:GTextInput;
	}
}